package com.sicnu.startup.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sicnu.startup.entity.News;
import com.sicnu.startup.result.Result;
import com.sicnu.startup.service.NewsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zr
 * @since 2022-01-08
 */
@RestController
@RequestMapping("/startup/news")
@CrossOrigin
public class NewsController {
    @Resource
    private NewsService newsService;

    /**
     * 分页查询新闻
     *
     * @param current
     * @param limit
     * @return
     */
    @GetMapping("pageNews/{current}/{limit}")
    public Result getPageNews(@PathVariable long current,
                              @PathVariable long limit) {
        Page<News> newsPage = new Page<>(current, limit);
        newsService.page(newsPage, null);
        return Result.ok(newsPage);
    }
}

